package com.example.javaee.controller;

import com.example.javaee.entity.Goods;
import com.example.javaee.service.GoodsService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * StackOverflow engineer
 * @ClassName BookController
 * @Description
 * @Author 杨理欢
 * @Date 2021/11/16 14:46
 * @Version V1.0
 */
@CrossOrigin
@Controller
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    @RequestMapping("findAllGoods")
    @ResponseBody
    public List<Goods> findAllGoods() {return goodsService.findAllGoods();
    }

    @RequestMapping("ascAllGoods")
    @ResponseBody
    public List<Goods> ascAllGoods() {
        return goodsService.ascAllGoods();
    }

    @RequestMapping("descAllGoods")
    @ResponseBody
    public List<Goods> descAllGoods() {
        return goodsService.descAllGoods();
    }

    @RequestMapping("findFuzzyGoods")
    @ResponseBody
    public List<Goods> findFuzzyGoods(String keywords) {
        return goodsService.findFuzzyGoods(keywords);
    }
    @RequestMapping("updateGoods")
    @ResponseBody
    public int updateGoods(@RequestBody Goods goods) {
        return goodsService.updateGoods(goods);
    }
    @RequestMapping("deleteGoods")
    @ResponseBody
    public int deleteGoods(int id) {

        return goodsService.deleteGoods(id);
    }
    @RequestMapping("addGoods")
    @ResponseBody
    public int addGoods(@RequestBody Goods goods) {
        return goodsService.addGoods(goods);
    }

    @RequestMapping("wxFindAllGoods")
    @ResponseBody
    public List<Goods> wxFindAllGoods() {
        return goodsService.wxFindAllGoods();
    }

    @RequestMapping("wxAscAllGoods")
    @ResponseBody
    public List<Goods> wxAscAllGoods() {
        return goodsService.wxAscAllGoods();
    }

    @RequestMapping("wxDescAllGoods")
    @ResponseBody
    public List<Goods> wxDescAllGoods() {
        return goodsService.wxDescAllGoods();
    }
}
